package com.admin.business.background.venusOaDepositAdmin;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 押金管理表
 * @create: 2023-11-01 11:33:29
 **/
@Service("venusOaDepositAdminService")
@Slf4j
public class VenusOaDepositAdminService{

    @Resource
    VenusOaDepositAdminDao venusOaDepositAdminDao;

    /**
     * 添加押金管理表,获取id数据
     *
     * @param cdoRequest - id:主键id
     *                   - user_id:操作人id
     *                   - org_id:公司id
     *                   - project_id:项目id
     *                   - code:订单号
     *                   - deposit_type:押金分类(1.车卡2.门禁卡3.电梯卡4.水电气卡5.房屋租赁6.设备设施租赁7.外包单位8.装修押金9.其他押金,10 电费押金 11 暖气押金 12 燃气押金  13冷气押金 14水费押金 )
     *                   - rel_area:区号
     *                   - rel_floor:楼号
     *                   - rel_unit:单元号
     *                   - rel_house:门牌号
     *                   - park_id:车牌号
     *                   - outsource_id:外包单位id
     *                   - deposit_money:押金金额
     *                   - payment_method:收款方式(1.现金2.银行卡对私3.银行卡对公4.支票5.POS机6.扫码支付7.微信8.支付宝)
     *                   - deposit_state:押金状态(1.已收押金2.待确认3.已退押金)
     *                   - deposit_recorks:备注
     *                   - deposit_images:凭证
     *                   - payment_time:收押金时间
     *                   - return_break_money:退押金违约金
     *                   - return_break_money_department:退押金违约金计入部门
     *                   - return_payee_name:退押金收款人姓名
     *                   - the_refund_way:退款方式( 1 银行转账 2 微信 3 支付宝 4 现金)
     *                   - return_payee_bank:退押金开户行
     *                   - return_payee_number:退押金卡号
     *                   - WeChat:微信收款码
     *                   - Alipay:支付宝账号
     *                   - return_user_id:退押金申请操作人
     *                   - return_recorks:退押金申请备注
     *                   - return_time:退押金申请时间
     *                   - should_be_back:应退押金
     *                   - rea_back:实退押金
     *                   - to_educt:扣除押金
     *                   - confirm_user_id:确认退款操作人
     *                   - public_and_private:1 对公 账户2 对私账户
     *                   - confirm_refund_method:确认退款方式
     *                   - confirm_refund_recorks:确认退款备注
     *                   - confirm_refund_images:确认退款凭证
     *                   - confirm_refund_time:确认退款时间
     *                   - confirm_refund_code:退款凭证号
     *                   - update_time:更新时间
     *                   - begin_time:开始时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return addVenusOaDepositAdmin(CDO cdoRequest) {
        venusOaDepositAdminDao.addVenusOaDepositAdmin(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新押金管理表数据
     *
     * @param cdoRequest - id:主键id
     *                   - user_id:操作人id
     *                   - org_id:公司id
     *                   - project_id:项目id
     *                   - code:订单号
     *                   - deposit_type:押金分类(1.车卡2.门禁卡3.电梯卡4.水电气卡5.房屋租赁6.设备设施租赁7.外包单位8.装修押金9.其他押金,10 电费押金 11 暖气押金 12 燃气押金  13冷气押金 14水费押金 )
     *                   - rel_area:区号
     *                   - rel_floor:楼号
     *                   - rel_unit:单元号
     *                   - rel_house:门牌号
     *                   - park_id:车牌号
     *                   - outsource_id:外包单位id
     *                   - deposit_money:押金金额
     *                   - payment_method:收款方式(1.现金2.银行卡对私3.银行卡对公4.支票5.POS机6.扫码支付7.微信8.支付宝)
     *                   - deposit_state:押金状态(1.已收押金2.待确认3.已退押金)
     *                   - deposit_recorks:备注
     *                   - deposit_images:凭证
     *                   - payment_time:收押金时间
     *                   - return_break_money:退押金违约金
     *                   - return_break_money_department:退押金违约金计入部门
     *                   - return_payee_name:退押金收款人姓名
     *                   - the_refund_way:退款方式( 1 银行转账 2 微信 3 支付宝 4 现金)
     *                   - return_payee_bank:退押金开户行
     *                   - return_payee_number:退押金卡号
     *                   - WeChat:微信收款码
     *                   - Alipay:支付宝账号
     *                   - return_user_id:退押金申请操作人
     *                   - return_recorks:退押金申请备注
     *                   - return_time:退押金申请时间
     *                   - should_be_back:应退押金
     *                   - rea_back:实退押金
     *                   - to_educt:扣除押金
     *                   - confirm_user_id:确认退款操作人
     *                   - public_and_private:1 对公 账户2 对私账户
     *                   - confirm_refund_method:确认退款方式
     *                   - confirm_refund_recorks:确认退款备注
     *                   - confirm_refund_images:确认退款凭证
     *                   - confirm_refund_time:确认退款时间
     *                   - confirm_refund_code:退款凭证号
     *                   - update_time:更新时间
     *                   - begin_time:开始时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return updateVenusOaDepositAdminById(CDO cdoRequest) {
        venusOaDepositAdminDao.updateVenusOaDepositAdminById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除押金管理表数据
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return deleteVenusOaDepositAdminById(CDO cdoRequest){
        int count = venusOaDepositAdminDao.deleteVenusOaDepositAdminById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除押金管理表数据
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return deleteVenusOaDepositAdmin(CDO cdoRequest) {
        int count = venusOaDepositAdminDao.deleteVenusOaDepositAdmin(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取押金管理表数据
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return getVenusOaDepositAdminById(CDO cdoRequest) {
        CDO cdoMapperResult = venusOaDepositAdminDao.getVenusOaDepositAdminById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取押金管理表数据列表
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return getVenusOaDepositAdminListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaDepositAdminDao.getVenusOaDepositAdminListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOaDepositAdminDao.getVenusOaDepositAdminCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取押金管理表数据列表
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author Ht
     * @create: 2023-11-01 11:33:29
     */
    @OpenApi
    public Return getVenusOaDepositAdminListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaDepositAdminDao.getVenusOaDepositAdminListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOaDepositAdminDao.getVenusOaDepositAdminCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
